Skip to content

JsonHighlighter

Base classes

Name Children Inherits
SyntaxHighlighter
prettyqt.gui.syntaxhighlighter

⋔ Inheritance diagram

graph TD
  357979336["syntaxhighlighters.JsonHighlighter"]
  1397204487["gui.SyntaxHighlighter"]
  1524332846["gui.SyntaxHighlighterMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  1270797816["QtGui.QSyntaxHighlighter"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  1397204487 --> 357979336
  1524332846 --> 1397204487
  3227531497 --> 1524332846
  2751680898 --> 3227531497
  2751680898 --> 1524332846
  1270797816 --> 1397204487
  3984060476 --> 1270797816
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 DocStrings

Bases: SyntaxHighlighter

Source code in prettyqt/syntaxhighlighters/jsonhighlighter.py
class JsonHighlighter(gui.SyntaxHighlighter):
    def highlightBlock(self, text: str):
        """Highlight a block of code using the rules outlined in the Constructor."""
        for m in BRACKETS.finditer(text):
            self.setFormat(m.span()[0], m.span()[1] - m.span()[0], SYMBOL_FORMAT)

        text = text.replace('\\"', "  ")
        for m in REGEXP1.finditer(text):
            self.setFormat(m.span()[0], m.span()[1] - m.span()[0], NAME_FORMAT)
        for m in REGEXP2.finditer(text):
            self.setFormat(m.span()[0], m.span()[1] - m.span()[0], VALUE_FORMAT)

highlightBlock(text: str)

Highlight a block of code using the rules outlined in the Constructor.

Source code in prettyqt/syntaxhighlighters/jsonhighlighter.py
def highlightBlock(self, text: str):
    """Highlight a block of code using the rules outlined in the Constructor."""
    for m in BRACKETS.finditer(text):
        self.setFormat(m.span()[0], m.span()[1] - m.span()[0], SYMBOL_FORMAT)

    text = text.replace('\\"', "  ")
    for m in REGEXP1.finditer(text):
        self.setFormat(m.span()[0], m.span()[1] - m.span()[0], NAME_FORMAT)
    for m in REGEXP2.finditer(text):
        self.setFormat(m.span()[0], m.span()[1] - m.span()[0], VALUE_FORMAT)

:fa-brands-github: Show source on GitHub